#!/bin/bash
predeploy_dir=/data/soft/predeploy-shell

        echo "1) k9pf"
        echo "2) k9pay(us)"
        echo "3) k9ope"
        echo "4) k9openpf"
        echo "5) k9lg"
        echo "6) k9analysis"
        echo "7) k9cs"
        echo "8) k9dev"
        echo "9) k9mail"
        echo "10) k9nba"
        echo "11) k9official(us)"
        echo "12) k9game"
        echo "13) k9forum_us"
        echo "14) k9ope_inner"
        echo "15) project_1"
        echo "16) k9wiki"
	echo "17) monster(china)"
	echo "18) k9forum_cn"
	echo "19) k9paycallback"
	echo "20) cnk9pay(cn)"
	echo "21) cnk9official(cn)"
	echo "22) k9monster_us"
	echo "23) k9mmdzpk(china)"
	echo "24) k9officialope(cn)"
	echo "25) k9adminimpactmobi"
	echo "26) k9officialope(us)"
	echo "27) k9soulhunters"
	echo "28) k9developer_temp"
	echo "29) k9adstat"
	echo "30) k9soulhuntersgamewiki"
	echo "31) k9_soulhunters"
	echo "32) k9avalonpre"
	echo "33) k9logcollect"
	echo "34) k9mdeveloper"
	echo "35) k9opt"
	echo "36) k9impactmobi"
	echo "37) k9avalon"
	echo "38) k9mineheroes_pre"
	echo "39) k9email_util"
	echo "40) k9shot"
	echo "41) k9mineheroes"
	echo "42) k9crash_report"
	echo "43) k9adope(us)"
	echo "44) k9nba_adventure(cn)"
	echo "45) k9ec(us)"
	echo "46) k9ec_app(us)"
	echo "47) k9warriors_pre(us)"
	echo "48) k9_official(us)"
	echo "49) k9chat(us)"
	echo "50) k9yeqiuquan(us)"
	echo "51) k9im_app(dongjing@amazon)"
	echo "52) k9official_new(us)"
	echo "53) k9bbs_cn"
	echo "54) k9pps_forum(us)"
	echo "55) k9ppsg_office(us)"
	echo "56) k9bokelong_pre(us)"
	echo "57) k9bkl_officical(cn)"
	echo "58) k9monster2"
read -p "choice deploy application :" app
        [ "x$app" == "x1" ] && app='k9pf'
        [ "x$app" == "x2" ] && app='k9pay'
        [ "x$app" == "x3" ] && app='k9ope'
        [ "x$app" == "x4" ] && app='k9openpf'
        [ "x$app" == "x5" ] && app='k9lg'
        [ "x$app" == "x6" ] && app='k9analysis'
        [ "x$app" == "x7" ] && app='k9cs'
        [ "x$app" == "x8" ] && app='k9developer'
        [ "x$app" == "x9" ] && app='k9mail'
        [ "x$app" == "x10" ] && app='k9nba'
        [ "x$app" == "x11" ] && app='k9official'
        [ "x$app" == "x12" ] && app='k9game'
        [ "x$app" == "x13" ] && app='k9forum_us'
        [ "x$app" == "x14" ] && app='k9ope_inner'
	[ "x$app" == "x15" ] && app='project_1'
	[ "x$app" == "x16" ] && app='k9wiki'
	[ "x$app" == "x17" ] && app='monster'
	[ "x$app" == "x18" ] && app='k9forum_cn'
	[ "x$app" == "x19" ] && app='k9paycallback'
	[ "x$app" == "x20" ] && app='cnk9pay'
	[ "x$app" == "x21" ] && app='cnk9official'
	[ "x$app" == "x22" ] && app='k9monster_us'
	[ "x$app" == "x23" ] && app='k9mmdzpk'
	[ "x$app" == "x24" ] && app='cnk9officialope'
	[ "x$app" == "x25" ] && app='k9adminimpactmobi'
	[ "x$app" == "x26" ] && app='k9officialope'
	[ "x$app" == "x27" ] && app='k9soulhunters'
	[ "x$app" == "x28" ] && app='k9developer_temp'
	[ "x$app" == "x29" ] && app='k9adstat'
	[ "x$app" == "x30" ] && app='k9soulhuntersgamewiki'
	[ "x$app" == "x31" ] && app='k9_soulhunters'
	[ "x$app" == "x32" ] && app='k9avalonpre'
	[ "x$app" == "x33" ] && app='k9logcollect'
	[ "x$app" == "x34" ] && app='k9mdeveloper'
	[ "x$app" == "x35" ] && app='k9opt'
	[ "x$app" == "x36" ] && app='k9impactmobi'
	[ "x$app" == "x37" ] && app='k9avalon'
	[ "x$app" == "x38" ] && app='k9mineheroes_pre'
	[ "x$app" == "x39" ] && app='k9email_util'
	[ "x$app" == "x40" ] && app='k9shot'
	[ "x$app" == "x41" ] && app='k9mineheroes'
	[ "x$app" == "x42" ] && app='k9crash_report'
	[ "x$app" == "x43" ] && app='k9ad_ope'
	[ "x$app" == "x44" ] && app='k9nba_adventure'
	[ "x$app" == "x45" ] && app='k9ec'
	[ "x$app" == "x46" ] && app='k9ec_app'
	[ "x$app" == "x47" ] && app='k9warriors_pre'
	[ "x$app" == "x48" ] && app='k9_official'
	[ "x$app" == "x49" ] && app='k9chat'
	[ "x$app" == "x50" ] && app='k9yeqiuquan'
	[ "x$app" == "x51" ] && app='k9im_app'
	[ "x$app" == "x52" ] && app='k9official_new'
	[ "x$app" == "x53" ] && app='k9bbs_cn'
	[ "x$app" == "x54" ] && app='k9pps_forum'
	[ "x$app" == "x55" ] && app='k9ppsg_office'
	[ "x$app" == "x56" ] && app='k9bokelong_pre'
	[ "x$app" == "x57" ] && app='k9bkl_officical'
	[ "x$app" == "x58" ] && app='k9monster2'
cd $predeploy_dir

branch_pre=''
tmppwd=$(pwd)
if [ "$app" == "cnk9pay" -o "$app" == "cnk9official" -o "$app" == "cnk9officialope" ]
then
	app=`echo $app|sed "s/cn//g"`
	branch_pre='cn_'
fi

if [ -d ./KICK9_MERGE/$app ]
then
        cd ./KICK9_MERGE/$app
	echo
	echo -e "\033[32m 当前目录: `pwd` \033[0m"
	echo
        git checkout ${branch_pre}development
	echo 
	echo -e "\033[32m 当前分支: ${branch_pre}development \033[0m"
	echo 
        git pull
        git checkout ${branch_pre}release
	echo 
	echo -e "\033[32m 当前分支: ${branch_pre}release \033[0m"
	echo 
        git pull origin ${branch_pre}release
	echo 
	echo -e "\033[32m 开始merge \033[0m"
	echo 
        git merge ${branch_pre}development
	echo 
	echo -e "\033[32m merge完成 \033[0m"
	echo 
        git push origin ${branch_pre}release
        git checkout ${branch_pre}master
	echo 
	echo -e "\033[32m 当前分支: ${branch_pre}master \033[0m"
	echo 
        git pull origin ${branch_pre}master
        git merge ${branch_pre}release -m 'merge rlease'
        git push origin ${branch_pre}master
        git checkout ${branch_pre}development
else
        echo app error
        echo 'support apps : cnk9pay; k9analysis; k9cs; k9dev; k9lg; k9nba; k9official; k9ope; k9openpf; k9pay; k9pf;'
fi
cd $tmppwd
echo @ `date "+%F %T"` $app was merged and will be deloyed >> /data/soft/predeploy-shell/merge.log
